package com.tanhua.app.interceptor;

import com.tanhua.model.pojo.User;

public class UserHolder {
    private static ThreadLocal<User> threadLocal = new ThreadLocal<User>();

    public static User get() {
        return threadLocal.get();
    }

    public static void set(User user){
        threadLocal.set(user);
    }

    public static Long getUserId(){
        if (threadLocal.get() == null) {
            return null;
        }
        return threadLocal.get().getId();
    }

    public static String getMobile() {
        if (threadLocal.get() == null) {
            return null;
        }
        return threadLocal.get().getMobile();
    }

    public static void remove(){
        threadLocal.remove();
    }
}
